{% extends "base.html" %}

{% block title_block %}
	{% if user %}
		{{ block.super }}Profile :: {{ user.get_display_name }}
	{% else %}
		{{ block.super }}Profile :: Unknown profile
	{% endif %}
{% endblock %}

{% block page_content_block %}
	{% if user %}
		{% if user_is_current %}
			<div class="page_name understyle">My profile</div>
		{% else %}
			<div class="page_name understyle">Profile of {{ user.get_display_name }}</div>
		{% endif %}
		
		<div class="undertext_block">
			{% if user_is_current %}
			<form method="POST" action="">{% csrf_token %}
			{% endif %}
				<table id="user-properties">
					{% if user_is_current %}
						<tr><td><label for="input_nick">Nick:</label></td><td><input id="input_nick" type="text" name="nick" value="{{ user.nick }}"></td></tr>
						<tr><td>E-Mail:</td><td>{{ user.email }}</td></tr>
						<tr><td><label for="input_hide_email">Hide E-Mail:</label></td><td><input id="input_hide_email" type="checkbox" name="hide_email"{% if user.hide_email %} checked="checked"{% endif %}></td></tr>
						<tr><td><label for="input_lang">Language:</label></td><td>
							<select id="input_lang" name="lang">
								{% for lang in all_langs %}
									<option value="{{ lang }}"{% if user.lang == lang %} selected{% endif %}>{{ lang }}</option>
								{% endfor %}
							</select>
						</td></tr>
						<tr><td><label for="input_summary">Summary:</label></td><td>
							<textarea id="input_summary" name="summary" rows="4" cols="60">{{ user.summary }}</textarea>
						</td></tr>
					{% else %}
						<tr><td>Nick:</td><td>{{ user.nick }}</td></tr>
						<tr><td>E-Mail:</td><td>{% if not user.hide_email %}{{ user.email }}{% else %}N/A{% endif %}</td></tr>
						<tr><td><label for="input_summary">Summary:</label></td><td>
							<textarea disabled="true" id="input_summary" name="summary" rows="4" cols="60">{{ user.summary }}</textarea>
						</td></tr>
					{% endif %}
				</table>
				{% if user_is_current %}
					<input type="submit" name="save" value="Save changes" class="ui-button">
			</form>
				{% endif %}
		</div>
	{% else %}
		<div class="page_name understyle">Cannot find this user profile</div>
	{% endif %}
{% endblock %}
